﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Cashier_Service;
using Cashier.utils;
using System.Data;

namespace Cashier.usercontrols
{
    public class ComboBoxSupplier: ComboBox
    {
        private SupplierService supplierService;

        public ComboBoxSupplier()
        {
            this.supplierService = new SupplierService();
        }

        /// <summary>
        /// 绑定数据
        /// </summary>
        public void BindData()
        {
            try
            {
                DataTable dt = this.supplierService.GetSupplierTable(0, 0, null, null, "id", null);
                List<DataItem> list = new List<DataItem>();
                list.Add(DataItem.GetDataItem("", "0"));
                list.AddRange(DataItem.GetDataItemList(dt, "shortname", "", "supplier_no"));
                this.DataSource = list;
                this.DisplayMember = "displayMember";
                this.ValueMember = "valueMember";
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
